import unittest
import datetime

from Autotests.Cloud.Clients import FinancialService
from Autotests.Cloud.executor import ActionExecutor
from Autotests.BaseTest import BaseTestCase


class TestFinancialReport(BaseTestCase):
    def test_FinancialReport(self):
        executor = ActionExecutor()
        finserv = FinancialService()

        result = executor.enumeratePartners(executor.getPartnerInfo('IASO'), True)

        for p in result.partnerInfo:
            r = finserv.createObject('EnumeratePartnerTotalsByPeriodRequest')
            r.partnerId = p.id
            r.billingPeriod.startTime = datetime.datetime(2012, 1, 1).isoformat()
            r.billingPeriod.endTime = datetime.datetime.utcnow().isoformat()
            r.currency = 'EUR'
            r.filter = ''
            finserv.call('EnumeratePartnerTotalsByPeriod', r)

if __name__ == "__main__":
    unittest.main()